CC		= gcc
WARNINGS	= -Wall
PROC_OPT        = -march=x86-64

CFLAGS = $(WARNINGS) $(PROC_OPT)
SRCS    = solver.c dlx.c dlx_solver.c fifo.c scheduler.c stack.c
HEADERS = general.h sudoku.h solver.h dlx.h fifo.h scheduler.h stack.h

_OBJ  = $(SRCS:.c=.o)
ODIR  = objs
OBJS  = $(patsubst %,$(ODIR)/%,$(_OBJ))

dlx_solver: $(OBJS) $(HEADERS)
	$(CC) -O3 -g -pipe $(CFLAGS) -lpthread $(OBJS) -o $@

$(ODIR)/%.o : %.c $(HEADERS)
	$(CC) -O3 -g -pipe $(CFLAGS) -c $< -o $@

.PHONY: clean

debug: dlx_solver
	gdb dlx_solver -x gdb_cmd

memcheck: dlx_solver
	valgrind --tool=memcheck -v --leak-check=full --show-reachable=yes ./dlx_solver 4

profile: dlx_solver

run: dlx_solver
	./dlx_solver 4
clean:
	rm -f objs/*.o dlx_solver core *~ \#*
